package com.youngball.business.dao.redis;


import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.Subscription;
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

/**
 * Created by admin on 2015/11/30.
 */

@Repository("publishingDao")
public class PublishingDao extends BaseRedisDao<String ,String> {

    @Resource(name = "messageListener")
    private MessageListenerAdapter messageListenerAdapter;
    public void send(){


        /*this.getRedisTemplate().convertAndSend("chatroom","aaaa");*/

        RedisConnection redisConnection= this.getRedisTemplate().getConnectionFactory().getConnection();
        Subscription subscribe= redisConnection.getSubscription();
        redisConnection.subscribe(messageListenerAdapter,null);
        subscribe.unsubscribe();
    }
}
